export function useHttp() {
  const sendPostRequest = async (body: object) => {
    const url = 'http://192.168.42.219:8080/webapi/getorder'
    try {
      const response = await fetch(url, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(body),
      });
      if (response.ok) {
        console.log("http 发送成功");
        return await response.json();
      } else {
        throw new Error('请求失败');
      }
    } catch (error) {
      console.error('http 错误:', error);
      throw error;
    }
  };

  return { sendPostRequest };
}
  
